package com.hns.can.master.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.base.entity.SysUserEntity;
import com.hns.can.master.entity.AppComprScoreSetEntity;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
/**
 * 综合能力设置
 * @author:lan
 * @email:763836737@qq.com
 * @version Revision 2.0.0
 */
@Service
public class SysCompreAbilitySetService extends CommonService {

    /**
     * 查询企业综合评分设置
     * @param corpId
     * @return
     * @author:lan
     * @email:763836737@qq.com
     */
    @SuppressWarnings("unchecked")
    @Transactional
    public List<AppComprScoreSetEntity> getSysCompreAbilitySet(String corpId) {
        List<AppComprScoreSetEntity> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("sysCompreAbilitySet.getSysCompreAbilitySet", corpId), AppComprScoreSetEntity.class);
        return list;
    }

    /**
     * 新增、修改企业综合评分设置
     * @param user
     * @param entity
     * @author:lan
     * @email:763836737@qq.com
     */
    @Transactional
    public void modoifSysCompreAbilitySet(SysUserEntity user,AppComprScoreSetEntity entity) {
        String corpId= entity.getCorpId();
        BigDecimal mftCoef = entity.getMftCoef();
        BigDecimal eneCoef = entity.getEneCoef();
        BigDecimal bhvCoef = entity.getBhvCoef();
        BigDecimal mainCoef = entity.getMainCoef();
        Integer count = (Integer) sqlMapDao.selectOne("sysCompreAbilitySet.getSysCompreAbilitySetCount", corpId);
        entity.setCorpId(corpId);
        entity.setBhvCoef(bhvCoef);
        entity.setEneCoef(eneCoef);
        entity.setMainCoef(mainCoef);
        entity.setMftCoef(mftCoef);
        entity.setUpdateTime(new Date());
        entity.setUpdateUser(user.getAcctName());
        if (count > 0) {
            //修改
            commonEntityDao.update(entity);
        }else{
            //新增
            commonEntityDao.save(entity);
        }
    }
}
